import 'package:flutter/material.dart';
import 'package:x3_base_package/x3_base_package.dart';
import 'package:x3_business_core/business_customer/ful_components/business_customer_details_service_xyk_tab.dart';

class BusinessCustomerDetailsServiceXyk extends StatefulWidget {
  static final String sName = 'BusinessCustomerDetailsServiceXyk';

  @override
  _BusinessCustomerDetailsServiceXykState createState() => _BusinessCustomerDetailsServiceXykState();
}

class _BusinessCustomerDetailsServiceXykState extends State<BusinessCustomerDetailsServiceXyk> {
  dynamic _arguments;

  BaseTabBarPage _baseTabBarPage;

  @override
  void dispose() {
    _baseTabBarPage.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    _arguments = BaseRouterUtil.getArguments(context);
    String title = BaseUtils.getKeyData(_arguments, 'title').toString();
    return BaseScaffoldComponent(title: title, child: _buildMainScaffold());
  }

  Widget _buildMainScaffold() {
    return BaseScreenRefreshComponent(
      request: BaseScreenRequestModel('/vip/customer/server/tool/wishcardtype', method: BaseHttpMethodEnum.GET),
      controller: BaseFutureController(),
      builder: (BaseHttpResultModel result) {
        return _buildTabPage(result.data);
      },
    );
  }

  Widget _buildTabPage(List<dynamic> items) {
    String inputApi = _arguments['inputApi'] ?? '';
    String vipId = _arguments['vipId'] ?? '';
    List<BaseTabConfig> _tabs = items.map((e) => BaseTabConfig(text: e['value'], child: BusinessCustomerDetailsServiceXykTab(vipId: vipId, cardTypeId: e['key'], inputApi: inputApi))).toList();
    _baseTabBarPage = BaseTabBarPage(_tabs);
    return Column(
      children: [
        Container(width: double.infinity, color: Colors.white, alignment: Alignment.center, child: _baseTabBarPage.buildTabBar(context, isScrollable: true)),
        Expanded(child: _baseTabBarPage.buildTabView()),
      ],
    );
  }
}
